package DFS;

/**
 * create by Sun
 * 2018/8/13
 *
 * todo 全队列
 */
public class Dfs {
    private static int[] a=new int[10];
    private static int[] b=new int[10];
    private static int n;

    static void dfs(int step){
        if(step>n){
            for(int j=1;j<=n;j++){
                System.out.print(a[j]+" ");
            }
            System.out.println();
            return;
        }
        for(int i=1;i<=n;i++){
            if(b[i]==0){
                a[step]=i;
                b[i]=1;
                dfs(step+1);
                b[i]=0;
            }
        }
    }

    public static void main(String[] args) {
        Dfs dfs1 = new Dfs();
        dfs1.n=3;
        dfs(1);
    }
}
